<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	  window.onload = function(){

	  	var oDiv = document.getElementById('div1');


	  	/*

	  	oDiv.onclick = myalert;

	  	function myalert(){
	  		alert('hello!');
	  	}

		*/


		oDiv.onclick = function(){
	  		alert('hello!');
	  	}

	  	



	  }




	</script>

</head>
<body>
	<div id="div1">这是一个div元素</div>
</body>
</html>